<template>
<div>
  <el-dialog
    :title="title"
    :close-on-click-modal="false"
     v-dialogDrag
    :visible.sync="visible">
    <el-form :model="inputForm" size="small" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="method==='view'"
             label-width="120px">
      <el-row  :gutter="15">
        <el-col :span="12">
            <el-form-item label="排名" prop="ranking"
                :rules="[
                 ]">
              <el-input v-model="inputForm.ranking" placeholder="请填写排名"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="单位" prop="unit"
                :rules="[
                 ]">
              <el-input v-model="inputForm.unit" placeholder="请填写单位"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="分数" prop="score"
                :rules="[
                 ]">
              <el-input v-model="inputForm.score" placeholder="请填写分数"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="优秀" prop="aExcellence"
                :rules="[
                 ]">
              <el-input v-model="inputForm.aExcellence" placeholder="请填写优秀"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="良好" prop="aFine"
                :rules="[
                 ]">
              <el-input v-model="inputForm.aFine" placeholder="请填写良好"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="一般" prop="aGeneral"
                :rules="[
                 ]">
              <el-input v-model="inputForm.aGeneral" placeholder="请填写一般"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="较差" prop="aPoor"
                :rules="[
                 ]">
              <el-input v-model="inputForm.aPoor" placeholder="请填写较差"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="优秀良好率(%)" prop="aExcellfiRate"
                :rules="[
                 ]">
              <el-input v-model="inputForm.aExcellfiRate" placeholder="请填写优秀良好率(%)"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="优秀" prop="bExcellence"
                :rules="[
                 ]">
              <el-input v-model="inputForm.bExcellence" placeholder="请填写优秀"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="良好" prop="bFine"
                :rules="[
                 ]">
              <el-input v-model="inputForm.bFine" placeholder="请填写良好"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="一般" prop="bGeneral"
                :rules="[
                 ]">
              <el-input v-model="inputForm.bGeneral" placeholder="请填写一般"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="较差" prop="bPoor"
                :rules="[
                 ]">
              <el-input v-model="inputForm.bPoor" placeholder="请填写较差"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="弃权" prop="bWaiver"
                :rules="[
                 ]">
              <el-input v-model="inputForm.bWaiver" placeholder="请填写弃权"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="无效票" prop="bInvalidBallots"
                :rules="[
                 ]">
              <el-input v-model="inputForm.bInvalidBallots" placeholder="请填写无效票"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="优秀良好率(%)" prop="bExcellfiRate"
                :rules="[
                 ]">
              <el-input v-model="inputForm.bExcellfiRate" placeholder="请填写优秀良好率(%)"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="优秀" prop="cExcellence"
                :rules="[
                 ]">
              <el-input v-model="inputForm.cExcellence" placeholder="请填写优秀"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="良好" prop="cFine"
                :rules="[
                 ]">
              <el-input v-model="inputForm.cFine" placeholder="请填写良好"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="一般" prop="cGeneral"
                :rules="[
                 ]">
              <el-input v-model="inputForm.cGeneral" placeholder="请填写一般"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="较差" prop="cPoor"
                :rules="[
                 ]">
              <el-input v-model="inputForm.cPoor" placeholder="请填写较差"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="弃权" prop="cWaiver"
                :rules="[
                 ]">
              <el-input v-model="inputForm.cWaiver" placeholder="请填写弃权"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="优秀良好率(%)" prop="cExcellfiRate"
                :rules="[
                 ]">
              <el-input v-model="inputForm.cExcellfiRate" placeholder="请填写优秀良好率(%)"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="优秀" prop="cTalkExcellence"
                :rules="[
                 ]">
              <el-input v-model="inputForm.cTalkExcellence" placeholder="请填写优秀"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="良好" prop="cTalkFine"
                :rules="[
                 ]">
              <el-input v-model="inputForm.cTalkFine" placeholder="请填写良好"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="一般" prop="cTalkGeneral"
                :rules="[
                 ]">
              <el-input v-model="inputForm.cTalkGeneral" placeholder="请填写一般"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="较差" prop="cTalkPoor"
                :rules="[
                 ]">
              <el-input v-model="inputForm.cTalkPoor" placeholder="请填写较差"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="弃权" prop="cTalkWaiver"
                :rules="[
                 ]">
              <el-input v-model="inputForm.cTalkWaiver" placeholder="请填写弃权"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="优秀良好率(%)" prop="cTalkExcellfiRate"
                :rules="[
                 ]">
              <el-input v-model="inputForm.cTalkExcellfiRate" placeholder="请填写优秀良好率(%)"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="总优秀良好率(%)" prop="allExcellfiRate"
                :rules="[
                 ]">
              <el-input v-model="inputForm.allExcellfiRate" placeholder="请填写总优秀良好率(%)"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="目标管理考核成绩" prop="assessmentResult"
                :rules="[
                 ]">
              <el-input v-model="inputForm.assessmentResult" placeholder="请填写目标管理考核成绩"     ></el-input>
           </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="备注信息" prop="remarks"
                :rules="[
                 ]">
          <el-input type="textarea" v-model="inputForm.remarks" placeholder="请填写备注信息"     ></el-input>
           </el-form-item>
        </el-col>
        </el-row>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button size="small" @click="visible = false">关闭</el-button>
      <el-button size="small" type="primary" v-if="method != 'view'" @click="doSubmit()" v-noMoreClick>确定</el-button>
    </span>
  </el-dialog>
</div>
</template>

<script>
  export default {
    data () {
      return {
        title: '',
        method: '',
        visible: false,
        loading: false,
        inputForm: {
          id: '',
          ranking: '',
          unit: '',
          score: '',
          aExcellence: '',
          aFine: '',
          aGeneral: '',
          aPoor: '',
          aExcellfiRate: '',
          bExcellence: '',
          bFine: '',
          bGeneral: '',
          bPoor: '',
          bWaiver: '',
          bInvalidBallots: '',
          bExcellfiRate: '',
          cExcellence: '',
          cFine: '',
          cGeneral: '',
          cPoor: '',
          cWaiver: '',
          cExcellfiRate: '',
          cTalkExcellence: '',
          cTalkFine: '',
          cTalkGeneral: '',
          cTalkPoor: '',
          cTalkWaiver: '',
          cTalkExcellfiRate: '',
          allExcellfiRate: '',
          assessmentResult: '',
          remarks: ''
        }
      }
    },
    components: {
    },
    methods: {
      init (method, id) {
        this.method = method
        this.inputForm.id = id
        if (method === 'add') {
          this.title = `新建班子（教学）`
        } else if (method === 'edit') {
          this.title = '修改班子（教学）'
        } else if (method === 'view') {
          this.title = '查看班子（教学）'
        }
        this.visible = true
        this.loading = false
        this.$nextTick(() => {
          this.$refs.inputForm.resetFields()
          if (method === 'edit' || method === 'view') { // 修改或者查看
            this.loading = true
            this.$http({
              url: `/team/teaching/teamTeaching/queryById?id=${this.inputForm.id}`,
              method: 'get'
            }).then(({data}) => {
              this.inputForm = this.recover(this.inputForm, data.teamTeaching)
              this.loading = false
            })
          }
        })
      },
      // 表单提交
      doSubmit () {
        this.$refs['inputForm'].validate((valid) => {
          if (valid) {
            this.loading = true
            this.$http({
              url: `/team/teaching/teamTeaching/save`,
              method: 'post',
              data: this.inputForm
            }).then(({data}) => {
              this.loading = false
              if (data && data.success) {
                this.visible = false
                this.$message.success(data.msg)
                this.$emit('refreshDataList')
              }
            })
          }
        })
      }
    }
  }
</script>